package cn.iocoder.yudao.module.eval.dal.mysql.condition;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.eval.controller.admin.condition.vo.EvalApplicationConditionPageReqVO;
import cn.iocoder.yudao.module.eval.dal.dataobject.condition.EvalApplicationConditionDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 申报条件配置 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface EvalApplicationConditionMapper extends BaseMapperX<EvalApplicationConditionDO> {

    default PageResult<EvalApplicationConditionDO> selectPage(EvalApplicationConditionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EvalApplicationConditionDO>()
                .likeIfPresent(EvalApplicationConditionDO::getConditionName, reqVO.getConditionName())
                .eqIfPresent(EvalApplicationConditionDO::getProfessionCode, reqVO.getProfessionCode())
                .eqIfPresent(EvalApplicationConditionDO::getSkillLevel, reqVO.getSkillLevel())
                .eqIfPresent(EvalApplicationConditionDO::getEvaluationMethod, reqVO.getEvaluationMethod())
                .eqIfPresent(EvalApplicationConditionDO::getConditionType, reqVO.getConditionType())
                .eqIfPresent(EvalApplicationConditionDO::getIsRequired, reqVO.getIsRequired())
                .eqIfPresent(EvalApplicationConditionDO::getConditionStatus, reqVO.getConditionStatus())
                .betweenIfPresent(EvalApplicationConditionDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(EvalApplicationConditionDO::getConditionOrder)
                .orderByDesc(EvalApplicationConditionDO::getId));
    }

    default List<EvalApplicationConditionDO> selectList(EvalApplicationConditionPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<EvalApplicationConditionDO>()
                .likeIfPresent(EvalApplicationConditionDO::getConditionName, reqVO.getConditionName())
                .eqIfPresent(EvalApplicationConditionDO::getProfessionCode, reqVO.getProfessionCode())
                .eqIfPresent(EvalApplicationConditionDO::getSkillLevel, reqVO.getSkillLevel())
                .eqIfPresent(EvalApplicationConditionDO::getEvaluationMethod, reqVO.getEvaluationMethod())
                .eqIfPresent(EvalApplicationConditionDO::getConditionType, reqVO.getConditionType())
                .eqIfPresent(EvalApplicationConditionDO::getIsRequired, reqVO.getIsRequired())
                .eqIfPresent(EvalApplicationConditionDO::getConditionStatus, reqVO.getConditionStatus())
                .betweenIfPresent(EvalApplicationConditionDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(EvalApplicationConditionDO::getConditionOrder)
                .orderByDesc(EvalApplicationConditionDO::getId));
    }

    default List<EvalApplicationConditionDO> selectListByProfessionAndLevel(String professionCode, String skillLevel) {
        return selectList(new LambdaQueryWrapperX<EvalApplicationConditionDO>()
                .eq(EvalApplicationConditionDO::getProfessionCode, professionCode)
                .eq(EvalApplicationConditionDO::getSkillLevel, skillLevel)
                .eq(EvalApplicationConditionDO::getConditionStatus, 1)
                .orderByAsc(EvalApplicationConditionDO::getConditionOrder));
    }

    default List<EvalApplicationConditionDO> selectListByProfessionAndMethod(String professionCode, String evaluationMethod) {
        return selectList(new LambdaQueryWrapperX<EvalApplicationConditionDO>()
                .eq(EvalApplicationConditionDO::getProfessionCode, professionCode)
                .eq(EvalApplicationConditionDO::getEvaluationMethod, evaluationMethod)
                .eq(EvalApplicationConditionDO::getConditionStatus, 1)
                .orderByAsc(EvalApplicationConditionDO::getConditionOrder));
    }

}
